package com.youkeda.dewu.api;

import com.youkeda.dewu.model.ProductDetail;
import com.youkeda.dewu.model.Result;
import com.youkeda.dewu.service.ProductDetailService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 刘正星
 * @version 1.0.0
 * @ClassName ProductDetailApi.java
 * @Description TODO
 * @createTime 2020年10月08日 16:29:00
 */
@RestController
@RequestMapping("/api/productdetail")
public class ProductDetailApi {

    @Autowired
    private ProductDetailService productDetailService;
    @GetMapping("/productId")
    public Result<List<ProductDetail>> getProductDetail(String productId){
        Result<List<ProductDetail>> result = new Result<>();
        result.setSuccess(true);
        if (StringUtils.isEmpty(productId)){
            result.setSuccess(false);
            return result;
        }
        List<ProductDetail> productDetails = productDetailService.getByProductId(productId);
        result.setData(productDetails);
        result.setMessage("successful");
        return result;
    }
}
